//
//  EzMulticastServer.h
//  FFTEST_RTSP_TCP
//
//  Created by 刘跃龙 on 1/3/18.
//  Copyright © 2018 absolutemobile. All rights reserved.
//

#ifndef EzMulticastServer_h
#define EzMulticastServer_h

#include "EzTools.h"
#include <pthread.h>
#include <functional>
#include <string>
#include <map>

EZ_BEGIN

#define EzMulticastServer_Socket_Buffer_Size 10240

class EzMulticastServer
{
public:
    typedef void(*MulticastRecvCallback)(std::string,unsigned short int,std::string);
    EzMulticastServer(std::string multicastIP,unsigned short int multicastPort);
    ~EzMulticastServer();
public://settings
    void setRecvCallback(MulticastRecvCallback callback){m_callback = callback;};
public:
    bool start();
    bool stop();
    bool multicastData(std::string data);
    bool unicastData(std::string,unsigned short int,std::string data);
private://settings
    
    pthread_t m_thread;
public://Recv
    MulticastRecvCallback m_callback;
    bool m_isWork;
    int m_socket;
//    static void thread_Revc(EzMulticastServer* self);
    std::string m_multicastIP;
    unsigned short int m_multicastPort;
};

EZ_END

#endif /* EzMulticastServer_h */
